home *** CD-ROM | disk | FTP | other *** search
/ Die Ultimative Software-P…i Collection 1996 & 1997 / Die Ultimative Software-Pakete CD-ROM fur Atari Collection 1996 & 1997.iso / g / gnu_c / info.lzh / INFO / GCC_INFO.11 < prev    next >
Encoding:
GNU Info File  |  1993-10-21  |  51.0 KB  |  1,106 lines

  1. This is Info file gcc.info, produced by Makeinfo-1.54 from the input
  2. file gcc.texi.
  3.  
  4.    This file documents the use and the internals of the GNU compiler.
  5.  
  6.    Copyright (C) 1988, 1989, 1992, 1993 Free Software Foundation, Inc.
  7.  
  8.    Permission is granted to make and distribute verbatim copies of this
  9. manual provided the copyright notice and this permission notice are
  10. preserved on all copies.
  11.  
  12.    Permission is granted to copy and distribute modified versions of
  13. this manual under the conditions for verbatim copying, provided also
  14. that the sections entitled "GNU General Public License" and "Protect
  15. Your Freedom--Fight `Look And Feel'" are included exactly as in the
  16. original, and provided that the entire resulting derived work is
  17. distributed under the terms of a permission notice identical to this
  18. one.
  19.  
  20.    Permission is granted to copy and distribute translations of this
  21. manual into another language, under the above conditions for modified
  22. versions, except that the sections entitled "GNU General Public
  23. License" and "Protect Your Freedom--Fight `Look And Feel'", and this
  24. permission notice, may be included in translations approved by the Free
  25. Software Foundation instead of in the original English.
  26.  
  27. File: gcc.info,  Node: Side Effects,  Next: Incdec,  Prev: RTL Declarations,  Up: RTL
  28.  
  29. Side Effect Expressions
  30. =======================
  31.  
  32.    The expression codes described so far represent values, not actions.
  33. But machine instructions never produce values; they are meaningful only
  34. for their side effects on the state of the machine.  Special expression
  35. codes are used to represent side effects.
  36.  
  37.    The body of an instruction is always one of these side effect codes;
  38. the codes described above, which represent values, appear only as the
  39. operands of these.
  40.  
  41. `(set LVAL X)'
  42.      Represents the action of storing the value of X into the place
  43.      represented by LVAL.  LVAL must be an expression representing a
  44.      place that can be stored in: `reg' (or `subreg' or
  45.      `strict_low_part'), `mem', `pc' or `cc0'.
  46.  
  47.      If LVAL is a `reg', `subreg' or `mem', it has a machine mode; then
  48.      X must be valid for that mode.
  49.  
  50.      If LVAL is a `reg' whose machine mode is less than the full width
  51.      of the register, then it means that the part of the register
  52.      specified by the machine mode is given the specified value and the
  53.      rest of the register receives an undefined value.  Likewise, if
  54.      LVAL is a `subreg' whose machine mode is narrower than the mode of
  55.      the register, the rest of the register can be changed in an
  56.      undefined way.
  57.  
  58.      If LVAL is a `strict_low_part' of a `subreg', then the part of the
  59.      register specified by the machine mode of the `subreg' is given
  60.      the value X and the rest of the register is not changed.
  61.  
  62.      If LVAL is `(cc0)', it has no machine mode, and X may be either a
  63.      `compare' expression or a value that may have any mode.  The
  64.      latter case represents a "test" instruction.  The expression `(set
  65.      (cc0) (reg:M N))' is equivalent to `(set (cc0) (compare (reg:M N)
  66.      (const_int 0)))'.  Use the former expression to save space during
  67.      the compilation.
  68.  
  69.      If LVAL is `(pc)', we have a jump instruction, and the
  70.      possibilities for X are very limited.  It may be a `label_ref'
  71.      expression (unconditional jump).  It may be an `if_then_else'
  72.      (conditional jump), in which case either the second or the third
  73.      operand must be `(pc)' (for the case which does not jump) and the
  74.      other of the two must be a `label_ref' (for the case which does
  75.      jump).  X may also be a `mem' or `(plus:SI (pc) Y)', where Y may
  76.      be a `reg' or a `mem'; these unusual patterns are used to
  77.      represent jumps through branch tables.
  78.  
  79.      If LVAL is neither `(cc0)' nor `(pc)', the mode of LVAL must not
  80.      be `VOIDmode' and the mode of X must be valid for the mode of LVAL.
  81.  
  82.      LVAL is customarily accessed with the `SET_DEST' macro and X with
  83.      the `SET_SRC' macro.
  84.  
  85. `(return)'
  86.      As the sole expression in a pattern, represents a return from the
  87.      current function, on machines where this can be done with one
  88.      instruction, such as Vaxes.  On machines where a multi-instruction
  89.      "epilogue" must be executed in order to return from the function,
  90.      returning is done by jumping to a label which precedes the
  91.      epilogue, and the `return' expression code is never used.
  92.  
  93.      Inside an `if_then_else' expression, represents the value to be
  94.      placed in `pc' to return to the caller.
  95.  
  96.      Note that an insn pattern of `(return)' is logically equivalent to
  97.      `(set (pc) (return))', but the latter form is never used.
  98.  
  99. `(call FUNCTION NARGS)'
  100.      Represents a function call.  FUNCTION is a `mem' expression whose
  101.      address is the address of the function to be called.  NARGS is an
  102.      expression which can be used for two purposes: on some machines it
  103.      represents the number of bytes of stack argument; on others, it
  104.      represents the number of argument registers.
  105.  
  106.      Each machine has a standard machine mode which FUNCTION must have.
  107.      The machine description defines macro `FUNCTION_MODE' to expand
  108.      into the requisite mode name.  The purpose of this mode is to
  109.      specify what kind of addressing is allowed, on machines where the
  110.      allowed kinds of addressing depend on the machine mode being
  111.      addressed.
  112.  
  113. `(clobber X)'
  114.      Represents the storing or possible storing of an unpredictable,
  115.      undescribed value into X, which must be a `reg', `scratch' or
  116.      `mem' expression.
  117.  
  118.      One place this is used is in string instructions that store
  119.      standard values into particular hard registers.  It may not be
  120.      worth the trouble to describe the values that are stored, but it
  121.      is essential to inform the compiler that the registers will be
  122.      altered, lest it attempt to keep data in them across the string
  123.      instruction.
  124.  
  125.      If X is `(mem:BLK (const_int 0))', it means that all memory
  126.      locations must be presumed clobbered.
  127.  
  128.      Note that the machine description classifies certain hard
  129.      registers as "call-clobbered".  All function call instructions are
  130.      assumed by default to clobber these registers, so there is no need
  131.      to use `clobber' expressions to indicate this fact.  Also, each
  132.      function call is assumed to have the potential to alter any memory
  133.      location, unless the function is declared `const'.
  134.  
  135.      If the last group of expressions in a `parallel' are each a
  136.      `clobber' expression whose arguments are `reg' or `match_scratch'
  137.      (*note RTL Template::.) expressions, the combiner phase can add
  138.      the appropriate `clobber' expressions to an insn it has
  139.      constructed when doing so will cause a pattern to be matched.
  140.  
  141.      This feature can be used, for example, on a machine that whose
  142.      multiply and add instructions don't use an MQ register but which
  143.      has an add-accumulate instruction that does clobber the MQ
  144.      register.  Similarly, a combined instruction might require a
  145.      temporary register while the constituent instructions might not.
  146.  
  147.      When a `clobber' expression for a register appears inside a
  148.      `parallel' with other side effects, the register allocator
  149.      guarantees that the register is unoccupied both before and after
  150.      that insn.  However, the reload phase may allocate a register used
  151.      for one of the inputs unless the `&' constraint is specified for
  152.      the selected alternative (*note Modifiers::.).  You can clobber
  153.      either a specific hard register, a pseudo register, or a `scratch'
  154.      expression; in the latter two cases, GNU CC will allocate a hard
  155.      register that is available there for use as a temporary.
  156.  
  157.      For instructions that require a temporary register, you should use
  158.      `scratch' instead of a pseudo-register because this will allow the
  159.      combiner phase to add the `clobber' when required.  You do this by
  160.      coding (`clobber' (`match_scratch' ...)).  If you do clobber a
  161.      pseudo register, use one which appears nowhere else--generate a
  162.      new one each time.  Otherwise, you may confuse CSE.
  163.  
  164.      There is one other known use for clobbering a pseudo register in a
  165.      `parallel': when one of the input operands of the insn is also
  166.      clobbered by the insn.  In this case, using the same pseudo
  167.      register in the clobber and elsewhere in the insn produces the
  168.      expected results.
  169.  
  170. `(use X)'
  171.      Represents the use of the value of X.  It indicates that the value
  172.      in X at this point in the program is needed, even though it may
  173.      not be apparent why this is so.  Therefore, the compiler will not
  174.      attempt to delete previous instructions whose only effect is to
  175.      store a value in X.  X must be a `reg' expression.
  176.  
  177.      During the delayed branch scheduling phase, X may be an insn.
  178.      This indicates that X previously was located at this place in the
  179.      code and its data dependencies need to be taken into account.
  180.      These `use' insns will be deleted before the delayed branch
  181.      scheduling phase exits.
  182.  
  183. `(parallel [X0 X1 ...])'
  184.      Represents several side effects performed in parallel.  The square
  185.      brackets stand for a vector; the operand of `parallel' is a vector
  186.      of expressions.  X0, X1 and so on are individual side effect
  187.      expressions--expressions of code `set', `call', `return',
  188.      `clobber' or `use'.
  189.  
  190.      "In parallel" means that first all the values used in the
  191.      individual side-effects are computed, and second all the actual
  192.      side-effects are performed.  For example,
  193.  
  194.           (parallel [(set (reg:SI 1) (mem:SI (reg:SI 1)))
  195.                      (set (mem:SI (reg:SI 1)) (reg:SI 1))])
  196.  
  197.      says unambiguously that the values of hard register 1 and the
  198.      memory location addressed by it are interchanged.  In both places
  199.      where `(reg:SI 1)' appears as a memory address it refers to the
  200.      value in register 1 *before* the execution of the insn.
  201.  
  202.      It follows that it is *incorrect* to use `parallel' and expect the
  203.      result of one `set' to be available for the next one.  For
  204.      example, people sometimes attempt to represent a jump-if-zero
  205.      instruction this way:
  206.  
  207.           (parallel [(set (cc0) (reg:SI 34))
  208.                      (set (pc) (if_then_else
  209.                                   (eq (cc0) (const_int 0))
  210.                                   (label_ref ...)
  211.                                   (pc)))])
  212.  
  213.      But this is incorrect, because it says that the jump condition
  214.      depends on the condition code value *before* this instruction, not
  215.      on the new value that is set by this instruction.
  216.  
  217.      Peephole optimization, which takes place together with final
  218.      assembly code output, can produce insns whose patterns consist of
  219.      a `parallel' whose elements are the operands needed to output the
  220.      resulting assembler code--often `reg', `mem' or constant
  221.      expressions.  This would not be well-formed RTL at any other stage
  222.      in compilation, but it is ok then because no further optimization
  223.      remains to be done.  However, the definition of the macro
  224.      `NOTICE_UPDATE_CC', if any, must deal with such insns if you
  225.      define any peephole optimizations.
  226.  
  227. `(sequence [INSNS ...])'
  228.      Represents a sequence of insns.  Each of the INSNS that appears in
  229.      the vector is suitable for appearing in the chain of insns, so it
  230.      must be an `insn', `jump_insn', `call_insn', `code_label',
  231.      `barrier' or `note'.
  232.  
  233.      A `sequence' RTX is never placed in an actual insn during RTL
  234.      generation.  It represents the sequence of insns that result from a
  235.      `define_expand' *before* those insns are passed to `emit_insn' to
  236.      insert them in the chain of insns.  When actually inserted, the
  237.      individual sub-insns are separated out and the `sequence' is
  238.      forgotten.
  239.  
  240.      After delay-slot scheduling is completed, an insn and all the
  241.      insns that reside in its delay slots are grouped together into a
  242.      `sequence'.  The insn requiring the delay slot is the first insn
  243.      in the vector; subsequent insns are to be placed in the delay slot.
  244.  
  245.      `INSN_ANNULLED_BRANCH_P' is set on an insn in a delay slot to
  246.      indicate that a branch insn should be used that will conditionally
  247.      annul the effect of the insns in the delay slots.  In such a case,
  248.      `INSN_FROM_TARGET_P' indicates that the insn is from the target of
  249.      the branch and should be executed only if the branch is taken;
  250.      otherwise the insn should be executed only if the branch is not
  251.      taken.  *Note Delay Slots::.
  252.  
  253.    These expression codes appear in place of a side effect, as the body
  254. of an insn, though strictly speaking they do not always describe side
  255. effects as such:
  256.  
  257. `(asm_input S)'
  258.      Represents literal assembler code as described by the string S.
  259.  
  260. `(unspec [OPERANDS ...] INDEX)'
  261. `(unspec_volatile [OPERANDS ...] INDEX)'
  262.      Represents a machine-specific operation on OPERANDS.  INDEX
  263.      selects between multiple machine-specific operations.
  264.      `unspec_volatile' is used for volatile operations and operations
  265.      that may trap; `unspec' is used for other operations.
  266.  
  267.      These codes may appear inside a `pattern' of an insn, inside a
  268.      `parallel', or inside an expression.
  269.  
  270. `(addr_vec:M [LR0 LR1 ...])'
  271.      Represents a table of jump addresses.  The vector elements LR0,
  272.      etc., are `label_ref' expressions.  The mode M specifies how much
  273.      space is given to each address; normally M would be `Pmode'.
  274.  
  275. `(addr_diff_vec:M BASE [LR0 LR1 ...])'
  276.      Represents a table of jump addresses expressed as offsets from
  277.      BASE.  The vector elements LR0, etc., are `label_ref' expressions
  278.      and so is BASE.  The mode M specifies how much space is given to
  279.      each address-difference.
  280.  
  281. File: gcc.info,  Node: Incdec,  Next: Assembler,  Prev: Side Effects,  Up: RTL
  282.  
  283. Embedded Side-Effects on Addresses
  284. ==================================
  285.  
  286.    Four special side-effect expression codes appear as memory addresses.
  287.  
  288. `(pre_dec:M X)'
  289.      Represents the side effect of decrementing X by a standard amount
  290.      and represents also the value that X has after being decremented.
  291.      x must be a `reg' or `mem', but most machines allow only a `reg'.
  292.      m must be the machine mode for pointers on the machine in use.
  293.      The amount X is decremented by is the length in bytes of the
  294.      machine mode of the containing memory reference of which this
  295.      expression serves as the address.  Here is an example of its use:
  296.  
  297.           (mem:DF (pre_dec:SI (reg:SI 39)))
  298.  
  299.      This says to decrement pseudo register 39 by the length of a
  300.      `DFmode' value and use the result to address a `DFmode' value.
  301.  
  302. `(pre_inc:M X)'
  303.      Similar, but specifies incrementing X instead of decrementing it.
  304.  
  305. `(post_dec:M X)'
  306.      Represents the same side effect as `pre_dec' but a different
  307.      value.  The value represented here is the value X has before being
  308.      decremented.
  309.  
  310. `(post_inc:M X)'
  311.      Similar, but specifies incrementing X instead of decrementing it.
  312.  
  313.    These embedded side effect expressions must be used with care.
  314. Instruction patterns may not use them.  Until the `flow' pass of the
  315. compiler, they may occur only to represent pushes onto the stack.  The
  316. `flow' pass finds cases where registers are incremented or decremented
  317. in one instruction and used as an address shortly before or after;
  318. these cases are then transformed to use pre- or post-increment or
  319. -decrement.
  320.  
  321.    If a register used as the operand of these expressions is used in
  322. another address in an insn, the original value of the register is used.
  323. Uses of the register outside of an address are not permitted within the
  324. same insn as a use in an embedded side effect expression because such
  325. insns behave differently on different machines and hence must be treated
  326. as ambiguous and disallowed.
  327.  
  328.    An instruction that can be represented with an embedded side effect
  329. could also be represented using `parallel' containing an additional
  330. `set' to describe how the address register is altered.  This is not
  331. done because machines that allow these operations at all typically
  332. allow them wherever a memory address is called for.  Describing them as
  333. additional parallel stores would require doubling the number of entries
  334. in the machine description.
  335.  
  336. File: gcc.info,  Node: Assembler,  Next: Insns,  Prev: Incdec,  Up: RTL
  337.  
  338. Assembler Instructions as Expressions
  339. =====================================
  340.  
  341.    The RTX code `asm_operands' represents a value produced by a
  342. user-specified assembler instruction.  It is used to represent an `asm'
  343. statement with arguments.  An `asm' statement with a single output
  344. operand, like this:
  345.  
  346.      asm ("foo %1,%2,%0" : "=a" (outputvar) : "g" (x + y), "di" (*z));
  347.  
  348. is represented using a single `asm_operands' RTX which represents the
  349. value that is stored in `outputvar':
  350.  
  351.      (set RTX-FOR-OUTPUTVAR
  352.           (asm_operands "foo %1,%2,%0" "a" 0
  353.                         [RTX-FOR-ADDITION-RESULT RTX-FOR-*Z]
  354.                         [(asm_input:M1 "g")
  355.                          (asm_input:M2 "di")]))
  356.  
  357. Here the operands of the `asm_operands' RTX are the assembler template
  358. string, the output-operand's constraint, the index-number of the output
  359. operand among the output operands specified, a vector of input operand
  360. RTX's, and a vector of input-operand modes and constraints.  The mode
  361. M1 is the mode of the sum `x+y'; M2 is that of `*z'.
  362.  
  363.    When an `asm' statement has multiple output values, its insn has
  364. several such `set' RTX's inside of a `parallel'.  Each `set' contains a
  365. `asm_operands'; all of these share the same assembler template and
  366. vectors, but each contains the constraint for the respective output
  367. operand.  They are also distinguished by the output-operand index
  368. number, which is 0, 1, ... for successive output operands.
  369.  
  370. File: gcc.info,  Node: Insns,  Next: Calls,  Prev: Assembler,  Up: RTL
  371.  
  372. Insns
  373. =====
  374.  
  375.    The RTL representation of the code for a function is a doubly-linked
  376. chain of objects called "insns".  Insns are expressions with special
  377. codes that are used for no other purpose.  Some insns are actual
  378. instructions; others represent dispatch tables for `switch' statements;
  379. others represent labels to jump to or various sorts of declarative
  380. information.
  381.  
  382.    In addition to its own specific data, each insn must have a unique
  383. id-number that distinguishes it from all other insns in the current
  384. function (after delayed branch scheduling, copies of an insn with the
  385. same id-number may be present in multiple places in a function, but
  386. these copies will always be identical and will only appear inside a
  387. `sequence'), and chain pointers to the preceding and following insns.
  388. These three fields occupy the same position in every insn, independent
  389. of the expression code of the insn.  They could be accessed with `XEXP'
  390. and `XINT', but instead three special macros are always used:
  391.  
  392. `INSN_UID (I)'
  393.      Accesses the unique id of insn I.
  394.  
  395. `PREV_INSN (I)'
  396.      Accesses the chain pointer to the insn preceding I.  If I is the
  397.      first insn, this is a null pointer.
  398.  
  399. `NEXT_INSN (I)'
  400.      Accesses the chain pointer to the insn following I.  If I is the
  401.      last insn, this is a null pointer.
  402.  
  403.    The first insn in the chain is obtained by calling `get_insns'; the
  404. last insn is the result of calling `get_last_insn'.  Within the chain
  405. delimited by these insns, the `NEXT_INSN' and `PREV_INSN' pointers must
  406. always correspond: if INSN is not the first insn,
  407.  
  408.      NEXT_INSN (PREV_INSN (INSN)) == INSN
  409.  
  410. is always true and if INSN is not the last insn,
  411.  
  412.      PREV_INSN (NEXT_INSN (INSN)) == INSN
  413.  
  414. is always true.
  415.  
  416.    After delay slot scheduling, some of the insns in the chain might be
  417. `sequence' expressions, which contain a vector of insns.  The value of
  418. `NEXT_INSN' in all but the last of these insns is the next insn in the
  419. vector; the value of `NEXT_INSN' of the last insn in the vector is the
  420. same as the value of `NEXT_INSN' for the `sequence' in which it is
  421. contained.  Similar rules apply for `PREV_INSN'.
  422.  
  423.    This means that the above invariants are not necessarily true for
  424. insns inside `sequence' expressions.  Specifically, if INSN is the
  425. first insn in a `sequence', `NEXT_INSN (PREV_INSN (INSN))' is the insn
  426. containing the `sequence' expression, as is the value of `PREV_INSN
  427. (NEXT_INSN (INSN))' is INSN is the last insn in the `sequence'
  428. expression.  You can use these expressions to find the containing
  429. `sequence' expression.
  430.  
  431.    Every insn has one of the following six expression codes:
  432.  
  433. `insn'
  434.      The expression code `insn' is used for instructions that do not
  435.      jump and do not do function calls.  `sequence' expressions are
  436.      always contained in insns with code `insn' even if one of those
  437.      insns should jump or do function calls.
  438.  
  439.      Insns with code `insn' have four additional fields beyond the three
  440.      mandatory ones listed above.  These four are described in a table
  441.      below.
  442.  
  443. `jump_insn'
  444.      The expression code `jump_insn' is used for instructions that may
  445.      jump (or, more generally, may contain `label_ref' expressions).  If
  446.      there is an instruction to return from the current function, it is
  447.      recorded as a `jump_insn'.
  448.  
  449.      `jump_insn' insns have the same extra fields as `insn' insns,
  450.      accessed in the same way and in addition contains a field
  451.      `JUMP_LABEL' which is defined once jump optimization has completed.
  452.  
  453.      For simple conditional and unconditional jumps, this field
  454.      contains the `code_label' to which this insn will (possibly
  455.      conditionally) branch.  In a more complex jump, `JUMP_LABEL'
  456.      records one of the labels that the insn refers to; the only way to
  457.      find the others is to scan the entire body of the insn.
  458.  
  459.      Return insns count as jumps, but since they do not refer to any
  460.      labels, they have zero in the `JUMP_LABEL' field.
  461.  
  462. `call_insn'
  463.      The expression code `call_insn' is used for instructions that may
  464.      do function calls.  It is important to distinguish these
  465.      instructions because they imply that certain registers and memory
  466.      locations may be altered unpredictably.
  467.  
  468.      A `call_insn' insn may be preceded by insns that contain a single
  469.      `use' expression and be followed by insns the contain a single
  470.      `clobber' expression.  If so, these `use' and `clobber'
  471.      expressions are treated as being part of the function call.  There
  472.      must not even be a `note' between the `call_insn' and the `use' or
  473.      `clobber' insns for this special treatment to take place.  This is
  474.      somewhat of a kludge and will be removed in a later version of GNU
  475.      CC.
  476.  
  477.      `call_insn' insns have the same extra fields as `insn' insns,
  478.      accessed in the same way.
  479.  
  480. `code_label'
  481.      A `code_label' insn represents a label that a jump insn can jump
  482.      to.  It contains two special fields of data in addition to the
  483.      three standard ones.  `CODE_LABEL_NUMBER' is used to hold the
  484.      "label number", a number that identifies this label uniquely among
  485.      all the labels in the compilation (not just in the current
  486.      function).  Ultimately, the label is represented in the assembler
  487.      output as an assembler label, usually of the form `LN' where N is
  488.      the label number.
  489.  
  490.      When a `code_label' appears in an RTL expression, it normally
  491.      appears within a `label_ref' which represents the address of the
  492.      label, as a number.
  493.  
  494.      The field `LABEL_NUSES' is only defined once the jump optimization
  495.      phase is completed and contains the number of times this label is
  496.      referenced in the current function.
  497.  
  498. `barrier'
  499.      Barriers are placed in the instruction stream when control cannot
  500.      flow past them.  They are placed after unconditional jump
  501.      instructions to indicate that the jumps are unconditional and
  502.      after calls to `volatile' functions, which do not return (e.g.,
  503.      `exit').  They contain no information beyond the three standard
  504.      fields.
  505.  
  506. `note'
  507.      `note' insns are used to represent additional debugging and
  508.      declarative information.  They contain two nonstandard fields, an
  509.      integer which is accessed with the macro `NOTE_LINE_NUMBER' and a
  510.      string accessed with `NOTE_SOURCE_FILE'.
  511.  
  512.      If `NOTE_LINE_NUMBER' is positive, the note represents the
  513.      position of a source line and `NOTE_SOURCE_FILE' is the source
  514.      file name that the line came from.  These notes control generation
  515.      of line number data in the assembler output.
  516.  
  517.      Otherwise, `NOTE_LINE_NUMBER' is not really a line number but a
  518.      code with one of the following values (and `NOTE_SOURCE_FILE' must
  519.      contain a null pointer):
  520.  
  521.     `NOTE_INSN_DELETED'
  522.           Such a note is completely ignorable.  Some passes of the
  523.           compiler delete insns by altering them into notes of this
  524.           kind.
  525.  
  526.     `NOTE_INSN_BLOCK_BEG'
  527.     `NOTE_INSN_BLOCK_END'
  528.           These types of notes indicate the position of the beginning
  529.           and end of a level of scoping of variable names.  They
  530.           control the output of debugging information.
  531.  
  532.     `NOTE_INSN_LOOP_BEG'
  533.     `NOTE_INSN_LOOP_END'
  534.           These types of notes indicate the position of the beginning
  535.           and end of a `while' or `for' loop.  They enable the loop
  536.           optimizer to find loops quickly.
  537.  
  538.     `NOTE_INSN_LOOP_CONT'
  539.           Appears at the place in a loop that `continue' statements
  540.           jump to.
  541.  
  542.     `NOTE_INSN_LOOP_VTOP'
  543.           This note indicates the place in a loop where the exit test
  544.           begins for those loops in which the exit test has been
  545.           duplicated.  This position becomes another virtual start of
  546.           the loop when considering loop invariants.
  547.  
  548.     `NOTE_INSN_FUNCTION_END'
  549.           Appears near the end of the function body, just before the
  550.           label that `return' statements jump to (on machine where a
  551.           single instruction does not suffice for returning).  This
  552.           note may be deleted by jump optimization.
  553.  
  554.     `NOTE_INSN_SETJMP'
  555.           Appears following each call to `setjmp' or a related function.
  556.  
  557.      These codes are printed symbolically when they appear in debugging
  558.      dumps.
  559.  
  560.    The machine mode of an insn is normally `VOIDmode', but some phases
  561. use the mode for various purposes; for example, the reload pass sets it
  562. to `HImode' if the insn needs reloading but not register elimination
  563. and `QImode' if both are required.  The common subexpression
  564. elimination pass sets the mode of an insn to `QImode' when it is the
  565. first insn in a block that has already been processed.
  566.  
  567.    Here is a table of the extra fields of `insn', `jump_insn' and
  568. `call_insn' insns:
  569.  
  570. `PATTERN (I)'
  571.      An expression for the side effect performed by this insn.  This
  572.      must be one of the following codes: `set', `call', `use',
  573.      `clobber', `return', `asm_input', `asm_output', `addr_vec',
  574.      `addr_diff_vec', `trap_if', `unspec', `unspec_volatile',
  575.      `parallel', or `sequence'.  If it is a `parallel', each element of
  576.      the `parallel' must be one these codes, except that `parallel'
  577.      expressions cannot be nested and `addr_vec' and `addr_diff_vec'
  578.      are not permitted inside a `parallel' expression.
  579.  
  580. `INSN_CODE (I)'
  581.      An integer that says which pattern in the machine description
  582.      matches this insn, or -1 if the matching has not yet been
  583.      attempted.
  584.  
  585.      Such matching is never attempted and this field remains -1 on an
  586.      insn whose pattern consists of a single `use', `clobber',
  587.      `asm_input', `addr_vec' or `addr_diff_vec' expression.
  588.  
  589.      Matching is also never attempted on insns that result from an `asm'
  590.      statement.  These contain at least one `asm_operands' expression.
  591.      The function `asm_noperands' returns a non-negative value for such
  592.      insns.
  593.  
  594.      In the debugging output, this field is printed as a number
  595.      followed by a symbolic representation that locates the pattern in
  596.      the `md' file as some small positive or negative offset from a
  597.      named pattern.
  598.  
  599. `LOG_LINKS (I)'
  600.      A list (chain of `insn_list' expressions) giving information about
  601.      dependencies between instructions within a basic block.  Neither a
  602.      jump nor a label may come between the related insns.
  603.  
  604. `REG_NOTES (I)'
  605.      A list (chain of `expr_list' and `insn_list' expressions) giving
  606.      miscellaneous information about the insn.  It is often information
  607.      pertaining to the registers used in this insn.
  608.  
  609.    The `LOG_LINKS' field of an insn is a chain of `insn_list'
  610. expressions.  Each of these has two operands: the first is an insn, and
  611. the second is another `insn_list' expression (the next one in the
  612. chain).  The last `insn_list' in the chain has a null pointer as second
  613. operand.  The significant thing about the chain is which insns appear
  614. in it (as first operands of `insn_list' expressions).  Their order is
  615. not significant.
  616.  
  617.    This list is originally set up by the flow analysis pass; it is a
  618. null pointer until then.  Flow only adds links for those data
  619. dependencies which can be used for instruction combination.  For each
  620. insn, the flow analysis pass adds a link to insns which store into
  621. registers values that are used for the first time in this insn.  The
  622. instruction scheduling pass adds extra links so that every dependence
  623. will be represented.  Links represent data dependencies,
  624. antidependencies and output dependencies; the machine mode of the link
  625. distinguishes these three types: antidependencies have mode
  626. `REG_DEP_ANTI', output dependencies have mode `REG_DEP_OUTPUT', and
  627. data dependencies have mode `VOIDmode'.
  628.  
  629.    The `REG_NOTES' field of an insn is a chain similar to the
  630. `LOG_LINKS' field but it includes `expr_list' expressions in addition
  631. to `insn_list' expressions.  There are several kinds of register notes,
  632. which are distinguished by the machine mode, which in a register note
  633. is really understood as being an `enum reg_note'.  The first operand OP
  634. of the note is data whose meaning depends on the kind of note.
  635.  
  636.    The macro `REG_NOTE_KIND (X)' returns the kind of register note.
  637. Its counterpart, the macro `PUT_REG_NOTE_KIND (X, NEWKIND)' sets the
  638. register note type of X to be NEWKIND.
  639.  
  640.    Register notes are of three classes: They may say something about an
  641. input to an insn, they may say something about an output of an insn, or
  642. they may create a linkage between two insns.  There are also a set of
  643. values that are only used in `LOG_LINKS'.
  644.  
  645.    These register notes annotate inputs to an insn:
  646.  
  647. `REG_DEAD'
  648.      The value in OP dies in this insn; that is to say, altering the
  649.      value immediately after this insn would not affect the future
  650.      behavior of the program.
  651.  
  652.      This does not necessarily mean that the register OP has no useful
  653.      value after this insn since it may also be an output of the insn.
  654.      In such a case, however, a `REG_DEAD' note would be redundant and
  655.      is usually not present until after the reload pass, but no code
  656.      relies on this fact.
  657.  
  658. `REG_INC'
  659.      The register OP is incremented (or decremented; at this level
  660.      there is no distinction) by an embedded side effect inside this
  661.      insn.  This means it appears in a `post_inc', `pre_inc',
  662.      `post_dec' or `pre_dec' expression.
  663.  
  664. `REG_NONNEG'
  665.      The register OP is known to have a nonnegative value when this
  666.      insn is reached.  This is used so that decrement and branch until
  667.      zero instructions, such as the m68k dbra, can be matched.
  668.  
  669.      The `REG_NONNEG' note is added to insns only if the pattern named
  670.      `decrement_and_branch_until_zero' is contained in the machine
  671.      description.
  672.  
  673. `REG_NO_CONFLICT'
  674.      This insn does not cause a conflict between OP and the item being
  675.      set by this insn even though it might appear that it does.  In
  676.      other words, if the destination register and OP could otherwise be
  677.      assigned the same register, this insn does not prevent that
  678.      assignment.
  679.  
  680.      Insns with this note are usually part of a block that begins with a
  681.      `clobber' insn specifying a multi-word pseudo register (which will
  682.      be the output of the block), a group of insns that each set one
  683.      word of the value and have the `REG_NO_CONFLICT' note attached,
  684.      and a final insn that copies the output to itself with an attached
  685.      `REG_EQUAL' note giving the expression being computed.  This block
  686.      is encapsulated with `REG_LIBCALL' and `REG_RETVAL' notes on the
  687.      first and last insns, respectively.
  688.  
  689. `REG_LABEL'
  690.      This insn uses OP, a `code_label', but is not a `jump_insn'.  The
  691.      presence of this note allows jump optimization to be aware that OP
  692.      is, in fact, being used.
  693.  
  694.    The following notes describe attributes of outputs of an insn:
  695.  
  696. `REG_EQUIV'
  697. `REG_EQUAL'
  698.      This note is only valid on an insn that sets only one register and
  699.      indicates that that register will be equal to OP at run time; the
  700.      scope of this equivalence differs between the two types of notes.
  701.      The value which the insn explicitly copies into the register may
  702.      look different from OP, but they will be equal at run time.  If the
  703.      output of the single `set' is a `strict_low_part' expression, the
  704.      note refers to the register that is contained in `SUBREG_REG' of
  705.      the `subreg' expression.
  706.  
  707.      For `REG_EQUIV', the register is equivalent to OP throughout the
  708.      entire function, and could validly be replaced in all its
  709.      occurrences by OP.  ("Validly" here refers to the data flow of the
  710.      program; simple replacement may make some insns invalid.)  For
  711.      example, when a constant is loaded into a register that is never
  712.      assigned any other value, this kind of note is used.
  713.  
  714.      When a parameter is copied into a pseudo-register at entry to a
  715.      function, a note of this kind records that the register is
  716.      equivalent to the stack slot where the parameter was passed.
  717.      Although in this case the register may be set by other insns, it
  718.      is still valid to replace the register by the stack slot
  719.      throughout the function.
  720.  
  721.      In the case of `REG_EQUAL', the register that is set by this insn
  722.      will be equal to OP at run time at the end of this insn but not
  723.      necessarily elsewhere in the function.  In this case, OP is
  724.      typically an arithmetic expression.  For example, when a sequence
  725.      of insns such as a library call is used to perform an arithmetic
  726.      operation, this kind of note is attached to the insn that produces
  727.      or copies the final value.
  728.  
  729.      These two notes are used in different ways by the compiler passes.
  730.      `REG_EQUAL' is used by passes prior to register allocation (such as
  731.      common subexpression elimination and loop optimization) to tell
  732.      them how to think of that value.  `REG_EQUIV' notes are used by
  733.      register allocation to indicate that there is an available
  734.      substitute expression (either a constant or a `mem' expression for
  735.      the location of a parameter on the stack) that may be used in
  736.      place of a register if insufficient registers are available.
  737.  
  738.      Except for stack homes for parameters, which are indicated by a
  739.      `REG_EQUIV' note and are not useful to the early optimization
  740.      passes and pseudo registers that are equivalent to a memory
  741.      location throughout there entire life, which is not detected until
  742.      later in the compilation, all equivalences are initially indicated
  743.      by an attached `REG_EQUAL' note.  In the early stages of register
  744.      allocation, a `REG_EQUAL' note is changed into a `REG_EQUIV' note
  745.      if OP is a constant and the insn represents the only set of its
  746.      destination register.
  747.  
  748.      Thus, compiler passes prior to register allocation need only check
  749.      for `REG_EQUAL' notes and passes subsequent to register allocation
  750.      need only check for `REG_EQUIV' notes.
  751.  
  752. `REG_UNUSED'
  753.      The register OP being set by this insn will not be used in a
  754.      subsequent insn.  This differs from a `REG_DEAD' note, which
  755.      indicates that the value in an input will not be used subsequently.
  756.      These two notes are independent; both may be present for the same
  757.      register.
  758.  
  759. `REG_WAS_0'
  760.      The single output of this insn contained zero before this insn.
  761.      OP is the insn that set it to zero.  You can rely on this note if
  762.      it is present and OP has not been deleted or turned into a `note';
  763.      its absence implies nothing.
  764.  
  765.    These notes describe linkages between insns.  They occur in pairs:
  766. one insn has one of a pair of notes that points to a second insn, which
  767. has the inverse note pointing back to the first insn.
  768.  
  769. `REG_RETVAL'
  770.      This insn copies the value of a multi-insn sequence (for example, a
  771.      library call), and OP is the first insn of the sequence (for a
  772.      library call, the first insn that was generated to set up the
  773.      arguments for the library call).
  774.  
  775.      Loop optimization uses this note to treat such a sequence as a
  776.      single operation for code motion purposes and flow analysis uses
  777.      this note to delete such sequences whose results are dead.
  778.  
  779.      A `REG_EQUAL' note will also usually be attached to this insn to
  780.      provide the expression being computed by the sequence.
  781.  
  782. `REG_LIBCALL'
  783.      This is the inverse of `REG_RETVAL': it is placed on the first
  784.      insn of a multi-insn sequence, and it points to the last one.
  785.  
  786. `REG_CC_SETTER'
  787. `REG_CC_USER'
  788.      On machines that use `cc0', the insns which set and use `cc0' set
  789.      and use `cc0' are adjacent.  However, when branch delay slot
  790.      filling is done, this may no longer be true.  In this case a
  791.      `REG_CC_USER' note will be placed on the insn setting `cc0' to
  792.      point to the insn using `cc0' and a `REG_CC_SETTER' note will be
  793.      placed on the insn using `cc0' to point to the insn setting `cc0'.
  794.  
  795.    These values are only used in the `LOG_LINKS' field, and indicate
  796. the type of dependency that each link represents.  Links which indicate
  797. a data dependence (a read after write dependence) do not use any code,
  798. they simply have mode `VOIDmode', and are printed without any
  799. descriptive text.
  800.  
  801. `REG_DEP_ANTI'
  802.      This indicates an anti dependence (a write after read dependence).
  803.  
  804. `REG_DEP_OUTPUT'
  805.      This indicates an output dependence (a write after write
  806.      dependence).
  807.  
  808.    For convenience, the machine mode in an `insn_list' or `expr_list'
  809. is printed using these symbolic codes in debugging dumps.
  810.  
  811.    The only difference between the expression codes `insn_list' and
  812. `expr_list' is that the first operand of an `insn_list' is assumed to
  813. be an insn and is printed in debugging dumps as the insn's unique id;
  814. the first operand of an `expr_list' is printed in the ordinary way as
  815. an expression.
  816.  
  817. File: gcc.info,  Node: Calls,  Next: Sharing,  Prev: Insns,  Up: RTL
  818.  
  819. RTL Representation of Function-Call Insns
  820. =========================================
  821.  
  822.    Insns that call subroutines have the RTL expression code `call_insn'.
  823. These insns must satisfy special rules, and their bodies must use a
  824. special RTL expression code, `call'.
  825.  
  826.    A `call' expression has two operands, as follows:
  827.  
  828.      (call (mem:FM ADDR) NBYTES)
  829.  
  830. Here NBYTES is an operand that represents the number of bytes of
  831. argument data being passed to the subroutine, FM is a machine mode
  832. (which must equal as the definition of the `FUNCTION_MODE' macro in the
  833. machine description) and ADDR represents the address of the subroutine.
  834.  
  835.    For a subroutine that returns no value, the `call' expression as
  836. shown above is the entire body of the insn, except that the insn might
  837. also contain `use' or `clobber' expressions.
  838.  
  839.    For a subroutine that returns a value whose mode is not `BLKmode',
  840. the value is returned in a hard register.  If this register's number is
  841. R, then the body of the call insn looks like this:
  842.  
  843.      (set (reg:M R)
  844.           (call (mem:FM ADDR) NBYTES))
  845.  
  846. This RTL expression makes it clear (to the optimizer passes) that the
  847. appropriate register receives a useful value in this insn.
  848.  
  849.    When a subroutine returns a `BLKmode' value, it is handled by
  850. passing to the subroutine the address of a place to store the value.
  851. So the call insn itself does not "return" any value, and it has the
  852. same RTL form as a call that returns nothing.
  853.  
  854.    On some machines, the call instruction itself clobbers some register,
  855. for example to contain the return address.  `call_insn' insns on these
  856. machines should have a body which is a `parallel' that contains both
  857. the `call' expression and `clobber' expressions that indicate which
  858. registers are destroyed.  Similarly, if the call instruction requires
  859. some register other than the stack pointer that is not explicitly
  860. mentioned it its RTL, a `use' subexpression should mention that
  861. register.
  862.  
  863.    Functions that are called are assumed to modify all registers listed
  864. in the configuration macro `CALL_USED_REGISTERS' (*note Register
  865. Basics::.) and, with the exception of `const' functions and library
  866. calls, to modify all of memory.
  867.  
  868.    Insns containing just `use' expressions directly precede the
  869. `call_insn' insn to indicate which registers contain inputs to the
  870. function.  Similarly, if registers other than those in
  871. `CALL_USED_REGISTERS' are clobbered by the called function, insns
  872. containing a single `clobber' follow immediately after the call to
  873. indicate which registers.
  874.  
  875. File: gcc.info,  Node: Sharing,  Next: Reading RTL,  Prev: Calls,  Up: RTL
  876.  
  877. Structure Sharing Assumptions
  878. =============================
  879.  
  880.    The compiler assumes that certain kinds of RTL expressions are
  881. unique; there do not exist two distinct objects representing the same
  882. value.  In other cases, it makes an opposite assumption: that no RTL
  883. expression object of a certain kind appears in more than one place in
  884. the containing structure.
  885.  
  886.    These assumptions refer to a single function; except for the RTL
  887. objects that describe global variables and external functions, and a
  888. few standard objects such as small integer constants, no RTL objects
  889. are common to two functions.
  890.  
  891.    * Each pseudo-register has only a single `reg' object to represent
  892.      it, and therefore only a single machine mode.
  893.  
  894.    * For any symbolic label, there is only one `symbol_ref' object
  895.      referring to it.
  896.  
  897.    * There is only one `const_int' expression with value 0, only one
  898.      with value 1, and only one with value -1.  Some other integer
  899.      values are also stored uniquely.
  900.  
  901.    * There is only one `pc' expression.
  902.  
  903.    * There is only one `cc0' expression.
  904.  
  905.    * There is only one `const_double' expression with value 0 for each
  906.      floating point mode.  Likewise for values 1 and 2.
  907.  
  908.    * No `label_ref' or `scratch' appears in more than one place in the
  909.      RTL structure; in other words, it is safe to do a tree-walk of all
  910.      the insns in the function and assume that each time a `label_ref'
  911.      or `scratch' is seen it is distinct from all others that are seen.
  912.  
  913.    * Only one `mem' object is normally created for each static variable
  914.      or stack slot, so these objects are frequently shared in all the
  915.      places they appear.  However, separate but equal objects for these
  916.      variables are occasionally made.
  917.  
  918.    * When a single `asm' statement has multiple output operands, a
  919.      distinct `asm_operands' expression is made for each output operand.
  920.      However, these all share the vector which contains the sequence of
  921.      input operands.  This sharing is used later on to test whether two
  922.      `asm_operands' expressions come from the same statement, so all
  923.      optimizations must carefully preserve the sharing if they copy the
  924.      vector at all.
  925.  
  926.    * No RTL object appears in more than one place in the RTL structure
  927.      except as described above.  Many passes of the compiler rely on
  928.      this by assuming that they can modify RTL objects in place without
  929.      unwanted side-effects on other insns.
  930.  
  931.    * During initial RTL generation, shared structure is freely
  932.      introduced.  After all the RTL for a function has been generated,
  933.      all shared structure is copied by `unshare_all_rtl' in
  934.      `emit-rtl.c', after which the above rules are guaranteed to be
  935.      followed.
  936.  
  937.    * During the combiner pass, shared structure within an insn can exist
  938.      temporarily.  However, the shared structure is copied before the
  939.      combiner is finished with the insn.  This is done by calling
  940.      `copy_rtx_if_shared', which is a subroutine of `unshare_all_rtl'.
  941.  
  942. File: gcc.info,  Node: Reading RTL,  Prev: Sharing,  Up: RTL
  943.  
  944. Reading RTL
  945. ===========
  946.  
  947.    To read an RTL object from a file, call `read_rtx'.  It takes one
  948. argument, a stdio stream, and returns a single RTL object.
  949.  
  950.    Reading RTL from a file is very slow.  This is no currently not a
  951. problem because reading RTL occurs only as part of building the
  952. compiler.
  953.  
  954.    People frequently have the idea of using RTL stored as text in a
  955. file as an interface between a language front end and the bulk of GNU
  956. CC.  This idea is not feasible.
  957.  
  958.    GNU CC was designed to use RTL internally only.  Correct RTL for a
  959. given program is very dependent on the particular target machine.  And
  960. the RTL does not contain all the information about the program.
  961.  
  962.    The proper way to interface GNU CC to a new language front end is
  963. with the "tree" data structure.  There is no manual for this data
  964. structure, but it is described in the files `tree.h' and `tree.def'.
  965.  
  966. File: gcc.info,  Node: Machine Desc,  Next: Target Macros,  Prev: RTL,  Up: Top
  967.  
  968. Machine Descriptions
  969. ********************
  970.  
  971.    A machine description has two parts: a file of instruction patterns
  972. (`.md' file) and a C header file of macro definitions.
  973.  
  974.    The `.md' file for a target machine contains a pattern for each
  975. instruction that the target machine supports (or at least each
  976. instruction that is worth telling the compiler about).  It may also
  977. contain comments.  A semicolon causes the rest of the line to be a
  978. comment, unless the semicolon is inside a quoted string.
  979.  
  980.    See the next chapter for information on the C header file.
  981.  
  982. * Menu:
  983.  
  984. * Patterns::            How to write instruction patterns.
  985. * Example::             An explained example of a `define_insn' pattern.
  986. * RTL Template::        The RTL template defines what insns match a pattern.
  987. * Output Template::     The output template says how to make assembler code
  988.                           from such an insn.
  989. * Output Statement::    For more generality, write C code to output
  990.                           the assembler code.
  991. * Constraints::         When not all operands are general operands.
  992. * Standard Names::      Names mark patterns to use for code generation.
  993. * Pattern Ordering::    When the order of patterns makes a difference.
  994. * Dependent Patterns::  Having one pattern may make you need another.
  995. * Jump Patterns::       Special considerations for patterns for jump insns.
  996. * Insn Canonicalizations::Canonicalization of Instructions
  997. * Peephole Definitions::Defining machine-specific peephole optimizations.
  998. * Expander Definitions::Generating a sequence of several RTL insns
  999.                          for a standard operation.
  1000. * Insn Splitting::    Splitting Instructions into Multiple Instructions
  1001. * Insn Attributes::     Specifying the value of attributes for generated insns.
  1002.  
  1003. File: gcc.info,  Node: Patterns,  Next: Example,  Up: Machine Desc
  1004.  
  1005. Everything about Instruction Patterns
  1006. =====================================
  1007.  
  1008.    Each instruction pattern contains an incomplete RTL expression, with
  1009. pieces to be filled in later, operand constraints that restrict how the
  1010. pieces can be filled in, and an output pattern or C code to generate
  1011. the assembler output, all wrapped up in a `define_insn' expression.
  1012.  
  1013.    A `define_insn' is an RTL expression containing four or five
  1014. operands:
  1015.  
  1016.   1. An optional name.  The presence of a name indicate that this
  1017.      instruction pattern can perform a certain standard job for the
  1018.      RTL-generation pass of the compiler.  This pass knows certain
  1019.      names and will use the instruction patterns with those names, if
  1020.      the names are defined in the machine description.
  1021.  
  1022.      The absence of a name is indicated by writing an empty string
  1023.      where the name should go.  Nameless instruction patterns are never
  1024.      used for generating RTL code, but they may permit several simpler
  1025.      insns to be combined later on.
  1026.  
  1027.      Names that are not thus known and used in RTL-generation have no
  1028.      effect; they are equivalent to no name at all.
  1029.  
  1030.   2. The "RTL template" (*note RTL Template::.) is a vector of
  1031.      incomplete RTL expressions which show what the instruction should
  1032.      look like.  It is incomplete because it may contain
  1033.      `match_operand', `match_operator', and `match_dup' expressions
  1034.      that stand for operands of the instruction.
  1035.  
  1036.      If the vector has only one element, that element is the template
  1037.      for the instruction pattern.  If the vector has multiple elements,
  1038.      then the instruction pattern is a `parallel' expression containing
  1039.      the elements described.
  1040.  
  1041.   3. A condition.  This is a string which contains a C expression that
  1042.      is the final test to decide whether an insn body matches this
  1043.      pattern.
  1044.  
  1045.      For a named pattern, the condition (if present) may not depend on
  1046.      the data in the insn being matched, but only the
  1047.      target-machine-type flags.  The compiler needs to test these
  1048.      conditions during initialization in order to learn exactly which
  1049.      named instructions are available in a particular run.
  1050.  
  1051.      For nameless patterns, the condition is applied only when matching
  1052.      an individual insn, and only after the insn has matched the
  1053.      pattern's recognition template.  The insn's operands may be found
  1054.      in the vector `operands'.
  1055.  
  1056.   4. The "output template": a string that says how to output matching
  1057.      insns as assembler code.  `%' in this string specifies where to
  1058.      substitute the value of an operand.  *Note Output Template::.
  1059.  
  1060.      When simple substitution isn't general enough, you can specify a
  1061.      piece of C code to compute the output.  *Note Output Statement::.
  1062.  
  1063.   5. Optionally, a vector containing the values of attributes for insns
  1064.      matching this pattern.  *Note Insn Attributes::.
  1065.  
  1066. File: gcc.info,  Node: Example,  Next: RTL Template,  Prev: Patterns,  Up: Machine Desc
  1067.  
  1068. Example of `define_insn'
  1069. ========================
  1070.  
  1071.    Here is an actual example of an instruction pattern, for the
  1072. 68000/68020.
  1073.  
  1074.      (define_insn "tstsi"
  1075.        [(set (cc0)
  1076.              (match_operand:SI 0 "general_operand" "rm"))]
  1077.        ""
  1078.        "*
  1079.      { if (TARGET_68020 || ! ADDRESS_REG_P (operands[0]))
  1080.          return \"tstl %0\";
  1081.        return \"cmpl #0,%0\"; }")
  1082.  
  1083.    This is an instruction that sets the condition codes based on the
  1084. value of a general operand.  It has no condition, so any insn whose RTL
  1085. description has the form shown may be handled according to this
  1086. pattern.  The name `tstsi' means "test a `SImode' value" and tells the
  1087. RTL generation pass that, when it is necessary to test such a value, an
  1088. insn to do so can be constructed using this pattern.
  1089.  
  1090.    The output control string is a piece of C code which chooses which
  1091. output template to return based on the kind of operand and the specific
  1092. type of CPU for which code is being generated.
  1093.  
  1094.    `"rm"' is an operand constraint.  Its meaning is explained below.
  1095.  
  1096. ə